<?php

require_once(sfConfig::get('sf_lib_dir').'/filter/base/BaseFormFilterPropel.class.php');

/**
 * Pedidos filter form base class.
 *
 * @package    tercermilenio
 * @subpackage filter
 * @author     Your name here
 */
class BasePedidosFormFilter extends BaseFormFilterPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'ped_cliente'      => new sfWidgetFormPropelChoice(array('model' => 'Clientes', 'add_empty' => true)),
      'ped_fecha'        => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'ped_fecha_limite' => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'ped_estado'       => new sfWidgetFormPropelChoice(array('model' => 'Estados', 'add_empty' => true)),
      'ped_usuario'      => new sfWidgetFormPropelChoice(array('model' => 'sfGuardUser', 'add_empty' => true)),
    ));

    $this->setValidators(array(
      'ped_cliente'      => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Clientes', 'column' => 'cli_id')),
      'ped_fecha'        => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'ped_fecha_limite' => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'ped_estado'       => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Estados', 'column' => 'est_id')),
      'ped_usuario'      => new sfValidatorPropelChoice(array('required' => false, 'model' => 'sfGuardUser', 'column' => 'id')),
    ));

    $this->widgetSchema->setNameFormat('pedidos_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Pedidos';
  }

  public function getFields()
  {
    return array(
      'ped_id'           => 'Number',
      'ped_cliente'      => 'ForeignKey',
      'ped_fecha'        => 'Date',
      'ped_fecha_limite' => 'Date',
      'ped_estado'       => 'ForeignKey',
      'ped_usuario'      => 'ForeignKey',
    );
  }
}
